package com.example.atv;

import android.app.Application;
import android.os.Bundle;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;

import java.util.HashMap;
import java.util.Map;

public class BaseActivity extends AppCompatActivity {

    public static final String TAG = "BaseActivity";

    public MyApplication getApp(){
        MyApplication application = (MyApplication) getApplication();
        return application;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getApp().addAtv(this.getClass().getName(),this);

        Log.i(TAG, "onCreate: ");
    }

    public Map<String,AppCompatActivity> getAtvMap(){
        return getApp().getAtvMap();
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.i(TAG, "onStart: ");
    }

    @Override
    protected void onRestart() {
        super.onRestart();

        Log.i(TAG, "onRestart: ");
    }

    @Override
    protected void onResume() {
        super.onResume();

        Log.i(TAG, "onResume: ");
    }

    @Override
    protected void onPause() {
        super.onPause();

        Log.i(TAG, "onPause: ");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.i(TAG, "onStop: ");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        getApp().removeAtv(this.getClass().getName());

        Log.i(TAG, "onDestroy: ");
    }
}
